
const fs = require('fs')
const mime = require('mime')

require('http').createServer((req, res) => {
  const urlString = req.url
  console.log(urlString)
  const type = mime.getType(urlString.split('.')[1])
  console.log(type)
  res.writeHead(200, {
    'content-type': type
  })
  const file = fs.readFileSync(`.${urlString}`)
  res.end(file)
}).listen(8080, () => {
  console.log('http://localhost:8080')
})



